Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
conventional-changelog
Advanced tools
The conventional-changelog npm package automates the generation of changelogs based on commit messages that follow the Conventional Commits specification. This tool is widely used to maintain a clear, readable history of project changes which can be easily communicated to other developers and users.
Generate changelog
This code demonstrates how to generate a changelog using the Angular preset. The changelog will be written to a file named 'CHANGELOG.md'.
const conventionalChangelog = require('conventional-changelog');
const fs = require('fs');
const changelogStream = conventionalChangelog({ preset: 'angular' });
changelogStream.pipe(fs.createWriteStream('CHANGELOG.md'));
Create a release
This code snippet shows how to automatically determine the semantic version bump based on commit messages. It uses the Angular preset to recommend a bump and then uses npm to update the project version accordingly.
const conventionalRecommendedBump = require('conventional-recommended-bump');
const exec = require('child_process').exec;
conventionalRecommendedBump({ preset: 'angular' }, (error, recommendation) => {
exec(`npm version ${recommendation.releaseType}`, (error, stdout, stderr) => {
console.log('Version bumped to', stdout);
});
});
standard-version is a utility for versioning using semver and CHANGELOG generation powered by Conventional Commits. It automates versioning and changelog generation but with a simpler setup compared to conventional-changelog, integrating these steps into a single command.
semantic-release automates the whole package release workflow including determining the next version number, generating the release notes, and publishing the package. This tool provides a more comprehensive solution compared to conventional-changelog by handling the entire release process in a CI/CD environment.
Lerna is a tool for managing JavaScript projects with multiple packages, known as monorepos. While it includes functionality for generating changelogs similar to conventional-changelog, its primary focus is on managing dependencies and publishing multiple packages from the same repository.
Generate a changelog from git metadata
$ npm install -g conventional-changelog
$ cd my-project
$ conventional-changelog -p angular -i CHANGELOG.md -w
This will not overwrite any previous changelog. The above generates a changelog based on commits since the last semver tag that match the pattern of a "Feature", "Fix", "Performance Improvement" or "Breaking Changes".
If you first time use this tool and want to generate all previous changelog, you could do
$ conventional-changelog -p angular -i CHANGELOG.md -w -r 0
This will overwrite any previous changelog if exist.
All available command line parameters can be listed using CLI : conventional-changelog --help
.
Hint: You can alias your command or add it to your package.json. EG: "changelog": "conventional-changelog -p angular -i CHANGELOG.md -w -r 0"
.
Or use one of the plugins if you are already using the tool: grunt/gulp/atom
package.json
conventionalChangelog
package.json
and CHANGELOG.md
filesThe reason why you should commit and tag after conventionalChangelog
is that the CHANGELOG should be included in the new release, hence gitRawCommitsOpts.from
defaults to the latest semver tag.
Please use this gist to make a release or change it to your needs.
$ npm install --save conventional-changelog
var conventionalChangelog = require('conventional-changelog');
conventionalChangelog({
preset: 'angular'
})
.pipe(process.stdout); // or any writable stream
Returns a readable stream.
Type: string
Possible values
It's recommended to use a preset so you don't have to define everything yourself. The preset values can be overwritten.
Type: object
Type: string
Default: closest package.json.
The location of your "package.json".
Type: function
Default: pass through.
A function that takes package.json
data as the argument and returns the modified data. Note this is performed before normalizing package.json data. Useful when you need to add a leading 'v' to your version or modify your repository url, etc.
Type: boolean
Default: false
Should the log be appended to existing data.
Type: number
Default: 1
How many releases of changelog you want to generate. It counts from the upcoming release. Useful when you forgot to generate any previous changelog. Set to 0
to regenerate all.
Type: function
Default: function() {}
A warn function. EG: grunt.verbose.writeln
Type: function
Default: get the version (without leading 'v') from tag and format date.
A transform function that applies after the parser and before the writer.
This is the place to modify the parsed commits.
####### commit
The commit from conventional-commits-parser.
####### cb
Callback when you are done.
####### this
this
arg of through2.
See the conventional-changelog-writer docs. There are some defaults or changes:
Default: normalized host found in package.json
.
Default: version found in package.json
.
Default: extracted from normalized package.json
repository.url
field.
Default: extracted from normalized package.json
repository.url
field.
Type: array
All git semver tags found in the repository. You can't overwrite this value.
Type: string
Default: previous tag or the first commit hash if no previous tag.
Type: string
Default: current tag or 'v'
+ version if no current tag.
Type: object
Your package.json
data. You can't overwrite this value.
Type: boolean
Default: true
if previousTag
and currentTag
are truthy.
Should link to the page that compares current tag with previous tag?
See the git-raw-commits docs. There are some defaults:
Default: '%B%n-hash-%n%H%n-gitTags-%n%d%n-committerDate-%n%ci'
Default: based on options.releaseCount
.
Default: only true
if options.append
is truthy.
See the conventional-commits-parser docs.
See the conventional-changelog-writer docs. There are some defaults:
Default: same as options.append
.
$ npm install --global conventional-changelog
$ conventional-changelog --help # for more details
This module has options append
and releaseCount
. However, it doesn't read your previous changelog. Reasons being:
So, when you build a parent module, you need to read the old logs and append or prepend to them based on options.append
. However, if options.releaseCount
is 0
you need to ignore any previous logs.
MIT
FAQs
Generate a changelog from git metadata.
The npm package conventional-changelog receives a total of 740,058 weekly downloads. As such, conventional-changelog popularity was classified as popular.
We found that conventional-changelog demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.